<?php
/**
 * Created by PhpStorm.
 * User: yadongw
 * Date: 15-5-26
 * Time: 下午7:46
 */
use UcxApiSdk\Client;
include 'common.php';

$client = new Client();
$client->setAccessToken($_COOKIE['ucx_access_token']);
$libraryResource = $client->getLibrary();
if($_POST){
	try{
		$libraryResource->create($_POST['Library']);
		header("location:index.php");
	}catch (\Exception $e){
		echo "Error: " . $e->getMessage();
	}
}
?>
<html>
<head>
	<link href="../static/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
	<script type="text/javascript" src="../static/jquery.min.js"></script>
	<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>

</head>
<body>
<h2 class="webform-title">Create Library</h2>
<form class="form-horizontal webform-box form-horizontal" method="post">
	<div class="form-group required">
		<label class="control-label col-md-4" for="library-name">Name *</label>
		<div class="col-md-6"><input type="text" id="library-name" class="form-control" name="Library[name]">

			<div class="help-block"></div></div>
	</div>
	<div class="form-group">
		<label class="control-label col-md-4" for="library-description">Description</label>
		<div class="col-md-6"><textarea id="library-description" class="form-control" name="Library[description]"></textarea>

			<div class="help-block"></div></div>
	</div>
	<div class="form-group">
		<div class="col-lg-offset-4 col-lg-8">
			<button type="submit" class="btn btn-primary">Upload</button>			</div>
	</div>
</form>
</body>
</html>